<!DOCTYPE html>
<html lang="en">
<style>
    ul.group-list li {
        white-space: nowrap;float: left;
        width: 150px; height: 25px;
        padding: 3px 5px;list-style-type: none;
        list-style-position: outside;border: 0px;margin: 0px;
    }
    input[type=checkbox], input[type=radio] {
        display: inline-block;
    }
</style>

{include file="Public/head"}

<body data-type="widgets">
<script src="/assets/js/theme.js"></script>
<div class="am-g tpl-g">

    {include file='Public:header'}
    {include file='Public:menu2'}



    <!-- 内容区域 -->
    <div class="tpl-content-wrapper" >
        <div class="row-content am-cf">
            <div class="row">

                <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                    <div class="widget am-cf">
                        <div class="widget-head am-cf">
                            <div class="widget-title am-fl">新增</div>
                            <div class="widget-function am-fr">
                                <a href="javascript:;" class="am-icon-cog"></a>
                            </div>
                        </div>
                        <div class="widget-body am-fr">
                            <form id="roleform" form="submit" class="am-form tpl-form-border-form tpl-form-border-br">
                                <div class="am-form-group">
                                    <label for="user-name" class="am-u-sm-3 am-form-label">会员等级 </label>
                                    <div class="am-u-sm-9">
                                        <input type="text" class="tpl-form-input" name="level_name" placeholder="请输入会员等级名称">
                                        <small>请输入会员等级名称。</small>
                                    </div>
                                </div>

                                <div class="am-form-group">
                                    <label for="user-name" class="am-u-sm-3 am-form-label">消费额度 </label>
                                    <div class="am-u-sm-9">
                                        <input type="number" class="tpl-form-input" name="amount" placeholder="请输入消费额度">
                                        <small>设置会员等级所需要的消费额度（人民币）。</small>
                                    </div>
                                </div>

                                <div class="am-form-group">
                                    <label for="user-name" class="am-u-sm-3 am-form-label">折扣率 </label>
                                    <div class="am-u-sm-9">
                                        <input type="number" class="tpl-form-input" name="discount" placeholder="请输入折扣率">
                                        <small>折扣率单位为百分比，如输入90，表示该会员等级的用户可以以商品原价的90%购买。</small>
                                    </div>
                                </div>

                                <div class="am-form-group">
                                    <label for="user-name" class="am-u-sm-3 am-form-label">等级描述 </label>
                                    <div class="am-u-sm-9">
                                        <textarea class="" rows="8" id="user-intro" name="describe" placeholder="请输入会员等级描述"></textarea>
                                        <small>会员等级描述信息。</small>
                                    </div>
                                </div>
                                <div class="am-form-group">
                                    <div class="am-u-sm-9 am-u-sm-push-3">
                                        <a onclick="javascript:history.back(-1);" ><input class="btn btn-default" type="reset" value="返回">&nbsp;&nbsp;&nbsp;&nbsp;</a>


                                        <input class="btn btn-info" type="submit"  value="提交">
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>

</body>
{include file='Public:script'}
{include file='Public:validation'}
<script>

    //提交
    function roleSubmit(){
        if($('[name="user_name"]').val() == '' ){
            layer.alert('角色名称不能为空', {icon: 2});
            return false;
        }
        var form=document.getElementById("roleform");
        var formData=new FormData(form);
        $.ajax({
            url:"{:Url('addData')}",
            type:'POST',
            data:formData,
            async: false,
            cache: false,
            contentType: false, //不设置内容类型
            processData: false, //不处理数据
            success:function(res){
                console.log(res);
                if (res.code != 200) {
                    layer.msg(res.msg, {shade: 0.5, time: 2000,icon: 2});
                    return false;
                }
                layer.msg(res.msg, {shade: 0.5, time: 2000, icon: 1}, function(){
                    window.location.href=document.referrer;

                });
            }
        });
        // $.post("{:Url('addData')}", formData, function (res) {
        // if (res.code != 200) {
        //     layer.msg(res.msg, {shade: 0.5, time: 1000,icon: 2});
        //     return false;
        // }
        // layer.msg(res.msg, {shade: 0.5, time: 1000, icon: 1}, function () {
        //     // location.reload();
        //     location.href = "{:url('index')}";
        // });
        // });
        // $('#roleform').submit();
    }
</script>

</html>